﻿package PinballCode {
	
	// coordinate of a given point
	public class Vertex {
		
		public var x:Number;	// x position
		public var y:Number;	// y position
		
		public function Vertex(x:Number,y:Number) {
			this.x=x;
			this.y=y;
		}
//<<<<<<< .mine
		public static function rotate(angle:Number,degrees:Boolean,point:Vertex):Vertex {
			if (degrees) angle *= Math.PI/180; // convert to radians
			var sin:Number = Math.sin(angle);
			var cos:Number = Math.cos(angle);
			var Xnew:Number = cos*point.x-sin*point.y;
			var Ynew:Number = sin*point.x+cos*point.y;
			return new Vertex(Xnew,Ynew);
		}
		
		// adds to vertexs together
		public static function add(p:Vertex,q:Vertex):Vertex {
			return new Vertex(p.x+q.x,p.y+q.y);
		}
		
		// subtracts a vertex from another
		public static function sub(p:Vertex,q:Vertex):Vertex {
			return new Vertex(q.x-p.x,q.y-p.y);
		}
		
		// toString
		public function toString():String {
			return "("+x+","+y+")";
			
		}
	}
}